/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import java.awt.Cursor;
import javax.swing.JLabel;
import modelo.Cotizacion;
import modelo.Planificacion;
import util.FechaUtil;
import util.SwingPanel;
import vista.cotizacion.ListadoCotizaciones;
import vista.planificacion.PantallaConsultarPlanificaciones;

/**
 *
 * @author Administrador
 */
public class VentanaHome extends javax.swing.JInternalFrame {

    private boolean deboRefrescar = true;
    /**
     * Creates new form VentanaHome
     */
    public VentanaHome() {
        initComponents();
        setSize(730, 481);
        initData();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblPlanFinalizada = new javax.swing.JLabel();
        lblCotAceptadas = new javax.swing.JLabel();
        lblCotCreacion = new javax.swing.JLabel();
        lblTareasFecha = new javax.swing.JLabel();
        lblCotPendiente1 = new javax.swing.JLabel();
        lblPlanCreacion = new javax.swing.JLabel();
        lblEjecEjecucion = new javax.swing.JLabel();
        lblEjecFinalizada = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));
        setClosable(true);
        setTitle("Bienvenido !");
        setOpaque(true);
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameClosing(evt);
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                formComponentShown(evt);
            }
        });
        addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                formFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                formFocusLost(evt);
            }
        });
        addHierarchyListener(new java.awt.event.HierarchyListener() {
            public void hierarchyChanged(java.awt.event.HierarchyEvent evt) {
                formHierarchyChanged(evt);
            }
        });
        addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                formPropertyChange(evt);
            }
        });
        getContentPane().setLayout(null);

        lblPlanFinalizada.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblPlanFinalizada.setForeground(new java.awt.Color(0, 153, 153));
        lblPlanFinalizada.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblPlanFinalizada.setText("(3)");
        lblPlanFinalizada.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblPlanFinalizadaMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lblPlanFinalizadaMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lblPlanFinalizadaMouseExited(evt);
            }
        });
        getContentPane().add(lblPlanFinalizada);
        lblPlanFinalizada.setBounds(20, 250, 190, 20);

        lblCotAceptadas.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblCotAceptadas.setForeground(new java.awt.Color(0, 153, 153));
        lblCotAceptadas.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblCotAceptadas.setText("(13)");
        lblCotAceptadas.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblCotAceptadasMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lblCotAceptadasMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lblCotAceptadasMouseExited(evt);
            }
        });
        getContentPane().add(lblCotAceptadas);
        lblCotAceptadas.setBounds(24, 142, 190, 15);

        lblCotCreacion.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblCotCreacion.setForeground(new java.awt.Color(0, 153, 153));
        lblCotCreacion.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblCotCreacion.setText("(1)");
        lblCotCreacion.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblCotCreacionMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lblCotCreacionMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lblCotCreacionMouseExited(evt);
            }
        });
        getContentPane().add(lblCotCreacion);
        lblCotCreacion.setBounds(24, 83, 190, 15);

        lblTareasFecha.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblTareasFecha.setForeground(new java.awt.Color(0, 153, 153));
        lblTareasFecha.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblTareasFecha.setText("---");
        lblTareasFecha.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblTareasFechaMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lblTareasFechaMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lblTareasFechaMouseExited(evt);
            }
        });
        getContentPane().add(lblTareasFecha);
        lblTareasFecha.setBounds(500, 83, 190, 15);

        lblCotPendiente1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblCotPendiente1.setForeground(new java.awt.Color(0, 153, 153));
        lblCotPendiente1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblCotPendiente1.setText("(3)");
        lblCotPendiente1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblCotPendiente1MouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lblCotPendiente1MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lblCotPendiente1MouseExited(evt);
            }
        });
        getContentPane().add(lblCotPendiente1);
        lblCotPendiente1.setBounds(24, 113, 190, 15);

        lblPlanCreacion.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblPlanCreacion.setForeground(new java.awt.Color(0, 153, 153));
        lblPlanCreacion.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblPlanCreacion.setText("(3)");
        lblPlanCreacion.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblPlanCreacionMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lblPlanCreacionMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lblPlanCreacionMouseExited(evt);
            }
        });
        getContentPane().add(lblPlanCreacion);
        lblPlanCreacion.setBounds(20, 220, 190, 20);

        lblEjecEjecucion.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblEjecEjecucion.setForeground(new java.awt.Color(0, 153, 153));
        lblEjecEjecucion.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblEjecEjecucion.setText("(3)");
        lblEjecEjecucion.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblEjecEjecucionMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lblEjecEjecucionMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lblEjecEjecucionMouseExited(evt);
            }
        });
        getContentPane().add(lblEjecEjecucion);
        lblEjecEjecucion.setBounds(10, 330, 200, 30);

        lblEjecFinalizada.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblEjecFinalizada.setForeground(new java.awt.Color(0, 153, 153));
        lblEjecFinalizada.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblEjecFinalizada.setText("(3)");
        lblEjecFinalizada.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblEjecFinalizadaMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lblEjecFinalizadaMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lblEjecFinalizadaMouseExited(evt);
            }
        });
        getContentPane().add(lblEjecFinalizada);
        lblEjecFinalizada.setBounds(10, 360, 200, 40);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/imagenes/HomeScreen.png"))); // NOI18N
        getContentPane().add(jLabel1);
        jLabel1.setBounds(0, 0, 720, 450);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    
    private void lblPlanFinalizadaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblPlanFinalizadaMouseClicked
        String filtro = "estado LIKE '"+Planificacion.ESTADO_FINALIZADA+"'";
        PantallaConsultarPlanificaciones win = new PantallaConsultarPlanificaciones(filtro);
        SwingPanel.getInstance().addWindow(win);
        win.setVisible(true);
    }//GEN-LAST:event_lblPlanFinalizadaMouseClicked

    private void lblPlanFinalizadaMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblPlanFinalizadaMouseEntered
        setCursor(new Cursor(Cursor.HAND_CURSOR));
    }//GEN-LAST:event_lblPlanFinalizadaMouseEntered

    private void lblPlanFinalizadaMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblPlanFinalizadaMouseExited
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }//GEN-LAST:event_lblPlanFinalizadaMouseExited

    private void lblCotAceptadasMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCotAceptadasMouseClicked
        String filtro = "estado LIKE '"+Cotizacion.ESTADO_ACEPTADO+"'";
        ListadoCotizaciones win = new ListadoCotizaciones(filtro);
        SwingPanel.getInstance().addWindow(win);
        win.setVisible(true); 
    }//GEN-LAST:event_lblCotAceptadasMouseClicked

    private void lblCotAceptadasMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCotAceptadasMouseEntered
        setCursor(new Cursor(Cursor.HAND_CURSOR));
    }//GEN-LAST:event_lblCotAceptadasMouseEntered

    private void lblCotAceptadasMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCotAceptadasMouseExited
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }//GEN-LAST:event_lblCotAceptadasMouseExited

    private void lblTareasFechaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblTareasFechaMouseClicked

    }//GEN-LAST:event_lblTareasFechaMouseClicked

    private void lblTareasFechaMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblTareasFechaMouseEntered

    }//GEN-LAST:event_lblTareasFechaMouseEntered

    private void lblTareasFechaMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblTareasFechaMouseExited

    }//GEN-LAST:event_lblTareasFechaMouseExited

    private void formInternalFrameClosing(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosing
        deboRefrescar = false; // Corto la ejecucion del HILO
    }//GEN-LAST:event_formInternalFrameClosing

    private void formFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_formFocusGained

    }//GEN-LAST:event_formFocusGained

    private void formFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_formFocusLost

    }//GEN-LAST:event_formFocusLost

    private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown

    }//GEN-LAST:event_formComponentShown

    private void formHierarchyChanged(java.awt.event.HierarchyEvent evt) {//GEN-FIRST:event_formHierarchyChanged

    }//GEN-LAST:event_formHierarchyChanged

    private void formPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_formPropertyChange
        if(evt.getPropertyName().equals("selected"))
        {
            initData();      
        }
    }//GEN-LAST:event_formPropertyChange

    private void lblCotCreacionMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCotCreacionMouseClicked
        String filtro = "estado LIKE '"+Cotizacion.ESTADO_EN_CREACION+"'";
        ListadoCotizaciones win = new ListadoCotizaciones(filtro);
        SwingPanel.getInstance().addWindow(win);
        win.setVisible(true); 
    }//GEN-LAST:event_lblCotCreacionMouseClicked

    private void lblCotCreacionMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCotCreacionMouseEntered
        setCursor(new Cursor(Cursor.HAND_CURSOR));
    }//GEN-LAST:event_lblCotCreacionMouseEntered

    private void lblCotCreacionMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCotCreacionMouseExited
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }//GEN-LAST:event_lblCotCreacionMouseExited

    private void lblCotPendiente1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCotPendiente1MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_lblCotPendiente1MouseClicked

    private void lblCotPendiente1MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCotPendiente1MouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_lblCotPendiente1MouseEntered

    private void lblCotPendiente1MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCotPendiente1MouseExited
        // TODO add your handling code here:
    }//GEN-LAST:event_lblCotPendiente1MouseExited

    private void lblPlanCreacionMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblPlanCreacionMouseClicked
        String filtro = "estado LIKE '"+Planificacion.ESTADO_CREADA+"'";
        PantallaConsultarPlanificaciones win = new PantallaConsultarPlanificaciones(filtro);
        SwingPanel.getInstance().addWindow(win);
        win.setVisible(true);
    }//GEN-LAST:event_lblPlanCreacionMouseClicked

    private void lblPlanCreacionMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblPlanCreacionMouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_lblPlanCreacionMouseEntered

    private void lblPlanCreacionMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblPlanCreacionMouseExited
        // TODO add your handling code here:
    }//GEN-LAST:event_lblPlanCreacionMouseExited

    private void lblEjecEjecucionMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblEjecEjecucionMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_lblEjecEjecucionMouseClicked

    private void lblEjecEjecucionMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblEjecEjecucionMouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_lblEjecEjecucionMouseEntered

    private void lblEjecEjecucionMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblEjecEjecucionMouseExited
        // TODO add your handling code here:
    }//GEN-LAST:event_lblEjecEjecucionMouseExited

    private void lblEjecFinalizadaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblEjecFinalizadaMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_lblEjecFinalizadaMouseClicked

    private void lblEjecFinalizadaMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblEjecFinalizadaMouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_lblEjecFinalizadaMouseEntered

    private void lblEjecFinalizadaMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblEjecFinalizadaMouseExited
        // TODO add your handling code here:
    }//GEN-LAST:event_lblEjecFinalizadaMouseExited

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel lblCotAceptadas;
    private javax.swing.JLabel lblCotCreacion;
    private javax.swing.JLabel lblCotPendiente1;
    private javax.swing.JLabel lblEjecEjecucion;
    private javax.swing.JLabel lblEjecFinalizada;
    private javax.swing.JLabel lblPlanCreacion;
    private javax.swing.JLabel lblPlanFinalizada;
    private javax.swing.JLabel lblTareasFecha;
    // End of variables declaration//GEN-END:variables

    private void initData() {
        setDataToLabel(lblTareasFecha,VentanaHomeGestor.getCotizacionesEnCreacion());
        setDataToLabel(lblPlanFinalizada,VentanaHomeGestor.getCotizacionesPendientes());
        setDataToLabel(lblCotAceptadas,VentanaHomeGestor.getCotizacionesAceptadas());
        setDataToLabel(lblPlanCreacion,VentanaHomeGestor.getPlanificacionesEnCreacion());
        setDataToLabel(lblPlanFinalizada,VentanaHomeGestor.getPlanificacionesFinalizadas());
        setDataToLabel(lblEjecEjecucion,VentanaHomeGestor.getEjecucionEnEjecucion());
        setDataToLabel(lblEjecFinalizada,VentanaHomeGestor.getEjecucionFinalizada());
        
        lblTareasFecha.setText(FechaUtil.getFechaActual());
    }
    
    private void setDataToLabel(JLabel lbl, int data)
    {
        lbl.setText("("+String.valueOf(data) +")");
    }

}
